package com.xomily.devops.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xomily.common.annotation.Log;
import com.xomily.common.core.controller.BaseController;
import com.xomily.common.core.domain.AjaxResult;
import com.xomily.common.enums.BusinessType;
import com.xomily.devops.domain.DevUrlLog;
import com.xomily.devops.service.IDevUrlLogService;
import com.xomily.common.utils.poi.ExcelUtil;
import com.xomily.common.core.page.TableDataInfo;

/**
 * 服务日志Controller
 * 
 * @author xomily
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/devops/urlLog")
public class DevUrlLogController extends BaseController
{
    @Autowired
    private IDevUrlLogService devUrlLogService;

    /**
     * 查询服务日志列表
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevUrlLog devUrlLog)
    {
        startPage();
        List<DevUrlLog> list = devUrlLogService.selectDevUrlLogList(devUrlLog);
        return getDataTable(list);
    }

    /**
     * 导出服务日志列表
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:export')")
    @Log(title = "服务日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DevUrlLog devUrlLog)
    {
        List<DevUrlLog> list = devUrlLogService.selectDevUrlLogList(devUrlLog);
        ExcelUtil<DevUrlLog> util = new ExcelUtil<DevUrlLog>(DevUrlLog.class);
        return util.exportExcel(list, "服务日志数据");
    }

    /**
     * 获取服务日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(devUrlLogService.selectDevUrlLogById(id));
    }

    /**
     * 新增服务日志
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:add')")
    @Log(title = "服务日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevUrlLog devUrlLog)
    {
        return toAjax(devUrlLogService.insertDevUrlLog(devUrlLog));
    }

    /**
     * 修改服务日志
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:edit')")
    @Log(title = "服务日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevUrlLog devUrlLog)
    {
        return toAjax(devUrlLogService.updateDevUrlLog(devUrlLog));
    }

    /**
     * 删除服务日志
     */
    @PreAuthorize("@ss.hasPermi('devops:urlLog:remove')")
    @Log(title = "服务日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(devUrlLogService.deleteDevUrlLogByIds(ids));
    }
}
